package server;

import java.util.Timer;


/**
 * This class schedules all the scheduled tasks for this server.
 * Each task will get called on pre-determined time
 */
public class Scheduler {
	
	public final static long DAY_IN_MILLIES = 60 * 60 * 24 * 1000;											//sec * min * hour * milliseconds = 1 Day in millies
	public final static long WEEK_IN_IN_MILLIES = DAY_IN_MILLIES * 7;

	public final static long DAY_IN_MILLIES_PRESENTATION = 60 * 1 * 1000;									// 5 minuts in millies - for presentation only! - simluate a day
	public final static long WEEK_IN_IN_MILLIES_PRESENTATION = DAY_IN_MILLIES_PRESENTATION ; 			// 10 minuts in millies - for presentation only! - simulate a week
	
	public final static int DAILY_TASKS = 1;
	public final static int WEEKLY_TASKS = 2;
	
	private Timer DailyTasks = null;
	private Timer WeeklyTasks = null;

	protected OBL_Server server;
	protected DB_Manager DB;
		

	/**
	 * Cunstructor for Scheduler
	 */
	public Scheduler(OBL_Server server,DB_Manager DB){
		
		this.server = server;
		this.DB = DB;
		
		DailyTasks = new Timer();
		DailyTasks.schedule(new SchedTask(DAILY_TASKS,this), 0L, DAY_IN_MILLIES);
	
		WeeklyTasks = new Timer();
		WeeklyTasks.schedule(new SchedTask(WEEKLY_TASKS,this),0L,WEEK_IN_IN_MILLIES_PRESENTATION);


	}	
}
